Documentation of TaskScheduler.au3

Created with HTMHelp © Sebastian Walter

Function List

Goto Top

_TS_Open

_TS_Open($sComputer = Default, $sUser = Default, $sDomain = Default, $sPassword = Default)
Description: Opens a connection to the Microsoft Task Scheduler Service on the local or a remote computer.
Return Value:
  Success - Object of the Task Scheduler Service
  Failure - Returns 0 and sets @error:
    101 - Error creating the COM error handler. @extended is set to the error code returned by _TS_ErrorNotify
    102 - Error creating the Task Scheduler Service. @extended is set to the COM error code
    103 - Error connecting to the Task Scheduler Service. @extended is set to the COM error code:
     0x80070005 - Access is denied to connect to the Task Scheduler service.
     0x8007000e - The application does not have enough memory to complete the operation or
     the user, password, or domain has at least one null and one non-null value.
     53 - This error is returned in the following situations:
     The computer name specified in the serverName parameter does not exist.
     When you are trying to connect to a Windows Server 2003 or Windows XP computer, and the remote computer does not have the
     File and Printer Sharing firewall exception enabled or the Remote Registry service is not running.
     When you are trying to connect to a Windows Vista computer, and the remote computer does not have the
     Remote Scheduled Tasks Management firewall exception enabled and the File and Printer Sharing firewall exception enabled, or the Remote Registry service is not running.
     50 - The user, password, or domain parameters cannot be specified when connecting to a remote Windows XP or Windows Server 2003 computer from a Windows Vista computer.
Parameters:
  $sComputer (Optional) - The name of the computer that you want to connect to. If this parameter is empty, the function will connect to the local computer.

  $sUser (Optional) - The user name that is used during the connection to $sComputer. If the user is not specified, then the current token is used.

  $sDomain (Optional) - The domain of the user specified in the user parameter.

  $sPassword (Optional) - The password that is used to connect to $sComputer. If user name and password are not specified, the current token is used.

Remarks: $sComputer can be specified as name or IP-Address. Name is network\computername or \\computername
Author: water
Goto Top

_TS_Close

_TS_Close()
Description: Closes the connection to the Microsoft Task Scheduler Service.
Return Value:
  Success - 1
Parameters:
  None
Author: water
Goto Top

_TS_ErrorNotify

_TS_ErrorNotify($iDebug, $sDebugFile = "")
Description: Sets or queries the debug level.
Return Value:
  Success (for $iDebug => 0) - 1, sets @extended to:
    0 - The COM error handler for this UDF was already active
    1 - A COM error handler has been initialized for this UDF
  Success (for $iDebug = -1) - one based one-dimensional array with the following elements:
    1 - Debug level. Value from 0 to 3. Check parameter $iDebug for details
    2 - Debug file. File to write the debugging info to as defined by parameter $sDebugFile
    3 - True if the COM error handler has been defined for this UDF. False if debugging is set off or a COM error handler was already defined
  Failure - 0, sets @error to:
    201 - $iDebug is not an integer or < -1 or > 4
    202 - Installation of the custom error handler failed. @extended is set to the error code returned by ObjEvent
    203 - COM error handler already set to another function
Parameters:
  $iDebug - Debug level. Allowed values are:
    -1 - Return the current settings
    0 - Disable debugging
    1 - Enable debugging. Output the debug info to the console
    2 - Enable Debugging. Output the debug info to a MsgBox
    3 - Enable Debugging. Output the debug info to a file defined by $sDebugFile
    4 - Enable Debugging. The COM errors will be handled (the script no longer crashes) without any output
  $sDebugFile (Optional) - File to write the debugging info to if $iDebug = 3 (Default = @ScriptDir & "TaskScheduler_Debug.txt")

Author: water
Goto Top

_TS_ErrorText

_TS_ErrorText($iErrorNumber, $bPrefix = True)
Description: Returns the full error message for an UDF function or the error/success message for the Task Scheduler API.
Return Value:
  Success - If $bPrefix = True: FunctionName (ErrorNumber): ErrorText, else: ErrorText
  Failure - Returns "" and sets @error:
    301 - Specified error number could not be found
Parameters:
  $iErrorNumber - Integer of the error returned by a function of this UDF or the Task Scheduler API
  $bPrefix (Optional) - True prefixes the error with functionname/errorname and errornumber (default = True)

Remarks: The Task Scheduler APIs return error/success as an HRESULT value e.g:
  $bPrefix = True: SCHED_S_TASK_NOT_SCHEDULED (0x00041305): One or more of the properties that are needed to run this task on a schedule have not been set.
  $bPrefix = False: One or more of the properties that are needed to run this task on a schedule have not been set.
  "S" as the second token of the APIs errorname denotes a success value, "E" an error value.
  |
  $bPrefix = True: ErrorNumber will be returned in hex notation (e.g. 0x00041305) if $iErrorNumber < 0
Author: water
Goto Top

_TS_ActionCreate

_TS_ActionCreate($oTaskDefinition, $iActionType, $sID = "")
Description: Create a new Action object for a new or already Registered Task.
Return Value:
  Success - Action object
  Failure - Returns 0 and sets @error:
    401 - $oTaskDefinition isn't an object or not a Task Definition object
    402 - The Action could not be created. @extended is set to the COM error code
Parameters:
  $oTaskDefinition - Task Definition object to add this Action to.
  $iActionType - The Action type to be created. Can be $TASK_ACTION_EXEC or $TASK_ACTION_COM_HANDLER
  of the TASK_ACTION_TYPE enumeration.All other types are no longer supported by MS.
  $sID (Optional) - ID for easier access to the object

Author: water
Goto Top

_TS_ActionDelete

_TS_ActionDelete($oTaskDefinition, $iIndex, $sID = "", $bDeleteAll = False)
Description: Delete a single or all Action objects by ID or index.
Return Value:
  Success - 1
  Failure - Returns 0 and sets @error:
    502 - The Action could not be deleted. @extended is set to the COM error code
    503 - The Actions could not be deleted. @extended is set to the COM error code
    504 - Either $iIndex or $sID has to be specified when $bDeleteAll is set to False
Parameters:
  $oTaskDefinition - Task Definition object of a new or Registered Task
  $iIndex - Delete the Action with the specified index (one based)
  $sID (Optional) - Deletes all Actions with the same ID (default = "")

  $bDeleteAll (Optional) - Removes all Actions (default = False)

Remarks: Set one of this three parameters to delete specific or all Actions: $iIndex, $sID, $bDeleteAll.
  The parameters will be processed in the following sequence:
  If $iIndex > 0 then delete by index, else if $sID <> "" then delete by ID, else if $bDeleteAll is True then delete all Actions
  |
  When you used $bDeleteAll = True you have to create at least one Action object as you can't register a Task without Actions.
Author: water
Goto Top

_TS_FolderCreate

_TS_FolderCreate($oService, $sFolder)
Description: Creates a Task Folder.
Return Value:
  Success - Object of the created Task Folder
  Failure - Returns 0 and sets @error:
    601 - Error accessing the TaskFolder collection. @extended is set to the COM error code
    602 - Specified $sFolder already exists
    603 - Error creating the specified TaskFolder. @extended is set to the COM error code
Parameters:
  $oService - Task Scheduler Service object as returned by _TS_Open
  $sFolder - The name that is used to identify the Folder. It is created on the root Folder
  If "FolderName\SubFolder1\SubFolder2" is specified, the entire Folder tree will be created if the Folders do not exist
Remarks: $sFolder has always to start at the root Folder (means you have to specify all the Folders from the root down even when they already exist)
Author: water
Goto Top

_TS_FolderDelete

_TS_FolderDelete($oService, $sFolder)
Description: Deletes a Task Folder.
Return Value:
  Success - 1
  Failure - Returns 0 and sets @error:
    701 - Error accessing the TaskFolder collection. @extended is set to the COM error code
    702 - Specified $sFolder does not exist. @extended is set to the COM error code
    703 - You can't delete a Folder before all subfolders have been deleted. @extended is set to the COM error code
    704 - Error deleting the specified TaskFolder. @extended is set to the COM error code
Parameters:
  $oService - Task Scheduler Service object as returned by _TS_Open
  $sFolder - The absolute path to the Folder to be deleted
  e.g. \Folder-Level1\Folder-Level2. No trailing backslash allowed.
Remarks: Before you can delete a Folder you have to delete all subfolders
Author: water
Goto Top

_TS_FolderExists

_TS_FolderExists($oService, $sFolder)
Description: Checks if a Task Folder exists.
Return Value:
  Success - 1 when Folder was found and 0 when Folder was not found
  Failure - Returns 0 and sets @error:
    801 - Error accessing the parent Folder of $sFolder (GetFolder). @extended is set to the COM error code
    802 - Error accessing the Taskfolder collection (GetFolders). @extended is set to the COM error code
Parameters:
  $oService - Task Scheduler Service object as returned by _TS_Open
  $sFolder - The absolute path to the Folder to be checked
  e.g. \Folder-Level1\Folder-Level2. No trailing backslash allowed.
Author: water
Goto Top

_TS_FolderGet

_TS_FolderGet($oService, $sFolder)
Description: Returns the object of the specified Folder.
Return Value:
  Success - Object of the specified Folder
  Failure - Returns 0 and sets @error:
    901 - Error accessing the specified Folder. @extended is set to the COM error code
Parameters:
  $oService - Task Scheduler Service object as returned by _TS_Open
  $sFolder - The absolute path to the Folder to be processed
  e.g. \Folder-Level1\Folder-Level2. No trailing backslash allowed.
Author: water
Goto Top

_TS_RunningTaskList

_TS_RunningTaskList($oService, $iShowHidden = 0)
Description: Returns a list of all currently running Tasks.
Return Value:
  Success - two-dimensional zero based array with the following information:
    0 - CurrentAction: Name of the current action that the running task is performing
    1 - EnginePID: Process ID for the engine (process) which is running the task
    2 - InstanceGuid: GUID identifier for this instance of the task
    3 - Name: Name of the task
    4 - Path: Path to where the task is stored
    5 - State: State of the running task (usually $TASK_STATE_RUNNING)
  Failure - Returns "" and sets @error:
    1001 - Error retrieving the RunningTasks collection. @extended is set to the COM error code
Parameters:
  $oService - Task Scheduler Service object as returned by _TS_Open
  $iShowHidden (Optional) - Returns hidden Tasks as well when set to 1 (default = 0)

Author: water
Goto Top

_TS_TaskCopy

_TS_TaskCopy($oService, $sSourceTaskPath)
Description: Copies the definition of an existing Task to a new Task Definition object.
Return Value:
  Success - Task Definition object
  Failure - Returns 0 and sets @error:
    1101 - Error returned when reading the source Task. @extended is set to the error returned by _TS_TaskExportXML
    1102 - Error returned when creating the target Task. @extended is set to the error code returned by _TS_TaskImportXML
Parameters:
  $oService - Task Scheduler Service object as returned by _TS_Open
  $sSourceTaskPath - Task Folder(s) and Task name of the source Task e.g. \folder1\folder1-1\source-task-name
Remarks: You can modify the Task Definition as needed before calling _TS_TaskRegister to create a new Task in the same
  or a different folder.
Author: water
Goto Top

_TS_TaskCreate

_TS_TaskCreate($oService)
Description: Create a Task Definition object so you can then set all needed properties using _TS_TaskPropertiesSet.
Return Value:
  Success - Task Definition object
  Failure - Returns 0 and sets @error:
    1201 - Error creating the Task Definition. @extended is set to the COM error code
Parameters:
  $oService - Task Scheduler Service object as returned by _TS_Open
Author: water
Goto Top

_TS_TaskDelete

_TS_TaskDelete($oService, $sTaskPath)
Description: Delete a Task from the specified Task Folder.
Return Value:
  Success - 1
  Failure - Returns 0 and sets @error:
    1301 - The specified Task Folder does not exist. @extended is set to the @error returned by _TS_FolderExists
    1302 - The specified Task does not exist. @extended is set to the @error returned by _TS_TaskExists
    1303 - Error accessing the Task Folder. @extended is set to the @error returned by _TS_FolderGet
    1304 - Error deleting the Task. @extended is set to the COM error code
Parameters:
  $oService - Task Scheduler Service object as returned by _TS_Open
  $sTaskPath - Task path (Folder plus Task name) to be deleted e.g. \folder1\folder1-1\task-name
Author: water
Goto Top

_TS_TaskExists

_TS_TaskExists($oService, $sTaskPath)
Description: Checks if a Task exists.
Return Value:
  Success - Returns 1 when the Task was found and 0 when the Task was not found
  Failure - Returns 0 and sets @error:
    1401 - Error accessing the specified Taskfolder. @extended is set to the COM error code
    1402 - Error retrieving the Tasks collection. @extended is set to the COM error code
Parameters:
  $oService - Task Scheduler Service object as returned by _TS_Open
  $sTaskPath - Task path (Folder plus Task name) to process
Remarks: This function even checks hidden Tasks
Author: water
Goto Top

_TS_TaskExportXML

_TS_TaskExportXML($oService, $sTask, $sXMLOutput = Default)
Description: Returns the XML representation of a single Task and writes it to a file or returns it in an array.
Return Value:
  Success - 1 if written to a file, one-dimensional zero based array holding the XML.
  Failure - Returns 0 and sets @error:
    1501 - Error returned by _TS_TaskGet. @extended is set to the COM error code
    1502 - Error opening the output file.
Parameters:
  $oService - Task Scheduler Service object as returned by _TS_Open
  $sTaskPath - Task path (Folder plus Task name) to process
  $sXMLOutput (Optional) - Destination to export the XML to. If not specified the XML gets returned as an array (default)

Remarks: An existing file will be overwritten.
Author: water
Goto Top

_TS_TaskGet

_TS_TaskGet($oService, $sTaskPath, $bReturnFlag = 0)
Description: Returns the Task or Task Definition object of the specified Task.
Return Value:
  Success - Object of the Task
  Failure - Returns 0 and sets @error:
    1601 - Error accessing the specified Taskfolder. @extended is set to the COM error code
    1602 - Error retrieving the Tasks collection. @extended is set to the COM error code
    1603 - Task with the specified name could not be found in the Task Folder
Parameters:
  $oService - Task Scheduler Service object as returned by _TS_Open
  $sTaskPath - Task path (Folder plus Task name) to process
  $bReturnFlag (Optional) - Set to 1 if the function should return the Task.Definition object (default = Task object)

Author: water
Goto Top

_TS_TaskImportXML

_TS_TaskImportXML($oService, $iInputType, $vXMLInput)
Description: Imports a Task from an XML file or an array and returns a Task Definition object.
Return Value:
  Success - Object of the created Task Definition
  Failure - Returns 0 and sets @error:
    1702 - Error creating a new Task Definition. @extended is set to the COM error code
    1703 - Error creating a XML from the passed array. @extended is set to the COM error code
    1704 - Error creating a XML from the passed file. @extended is set to the COM error code
Parameters:
  $oService - Task Scheduler Service object as returned by _TS_Open
  $iInputType - 1 = $vXMLInput is a file to import the XML from, 2 = $vXMLInput is a XML string or a 1D XML array
  $vXMLInput - Input to import the XML from. Is either a string, an array or a file to import the XML from
Remarks: You can modify the Task Definition as needed before calling _TS_TaskRegister to create a new Task.
Author: water
Goto Top

_TS_TaskList

_TS_TaskList($oService, $vFolder = "\", $iShowHidden = 0, $iShowDisabled = 1, $iShowMS = 1, $iProperties = 0, $bReadable = True)
Description: Returns a list of all Tasks in a given Folder and all subfolders.
Return Value:
  Success - two-dimensional zero based array with the information requested by parameter $iProperties (see there)
  Failure - Returns "" and sets @error:
    1801 - Error accessing the specified Taskfolder. @extended is set to the COM error code
Parameters:
  $oService - Task Scheduler Service object as returned by _TS_Open
  $vFolder (Optional) - Task Folder to process either as string Folderpath (e.g. "\test\test2") or Folder object (default = "\" means: root Folder)

  $iShowHidden (Optional) - Returns hidden Tasks as well when set to 1 (default = 0)

  $iShowDisabled (Optional) - Returns disabled Tasks as well when set to 1 (default = 1)

  $iShowMS (Optional) - Returns Tasks in Microsoft Folders as well when set to 1 (default = 1)

  $iProperties (Optional) - A bitwise mask that indicates the properties to be returned (default = 0 = all properties) e.g. 5 returns Task name and State.

    Possible values (to select all 25 possible columns use the maximum value of 2^25 - 1 or 0 (which gets translated to 2^25 - 1):
     1 (2^0) - Task name
     2 (2^1) - Task Folder
     4 (2^2) - State
     8 (2^3) - Hidden
     16 (2^4) - Last Task result
     32 (2^5) - Last run
     64 (2^6) - Next run
     128 (2^7) - Missed runs
     256 (2^8) - Allow demand start
     512 (2^9) - AllowHardTerminate
     1024 (2^10) - DeleteExpiredTaskAfter
     2048 (2^11) - DisallowStartIfOnBatteries
     4096 (2^12) - ExecutionTimeLimit
     8192 (2^13) - MultipleInstances
     16384 (2^14) - Priority
     32768 (2^15) - RestartCount
     65536 (2^16) - RestartInterval
     131072 (2^17) - RunOnlyIfIdle
     262144 (2^18) - RunOnlyIfNetworkAvailable
     524288 (2^19) - StartWhenAvailable
     1048576 (2^20) - StopIfGoingOnBatteries
     2097152 (2^21) - WakeToRun
     4194304 (2^22) - Author
     8388608 (2^23) - Date
     16777216 (2^24) - Description
  $bReadable (Optional) - True translates some values (e.g. State to text, date/time to readable format and suppresses empty values).

Author: water
Goto Top

_TS_TaskListHeader

_TS_TaskListHeader($iProperties = 0)
Description: Returns the header line for function _TS_TaskList so you can pass this to _ArrayDisplay as parameter $sHeader.
Return Value:
  Success - Column headers separated by |
  Failure - Returns 0 and sets @error:
Parameters:
  $iProperties (Optional) - A bitwise mask that indicates the properties to be returned.

Remarks: For possible values for parameter $iProperties please see function _TS_TaskList
Author: water
Goto Top

_TS_TaskPropertiesGet

_TS_TaskPropertiesGet($oTaskService, $vTask, $iFormat = Default, $bIgnoreNoValues = Default, $sQuerySection = Default, $sQueryProperties = Default)
Description: Lists all or specified properties of a Task or Task Definition and returns an array or string or writes the properties to the console.
Return Value:
  Success - For $iFormat=1 or 2: Zero based two-dimensional array with the following information. Please see Remarks as well.
     0 - Section related to a COM object
     1 - Property name
     2 - Property value
     3 - Comment
  Success - For $iFormat=3: Writes the AutoIt array definition to the console
  Failure - Returns "" and sets @error
    1901 - Error returned by _TS_TaskGet. @extended is set to the COM error code. Most probably the Task could not be found
Parameters:
  $oService - Task Scheduler Service object as returned by _TS_Open
  $vTask - Path and name or object of the Registered Task to process or a Task Definition object
  $iFormat - Format of the output. Can be one of the following values
    1 - User friendly format (default). Please see Remarks
    2 - Format you can use as input to _TS_TaskPropertiesSet (just the content of the array)
    3 - Format you can use as input to _TS_TaskPropertiesSet (full AutoIt syntax to define the array - without XML and written to the console)
  $bIgnoreNoValues (Optional) - If set to True properties without a value do not get returned (default = False)

  $sQuerySection (Optional) - Name of the Scheduler object to retrieve the properties from. If set to "" all objects will be retrieved (default = "")

  $sQueryProperties (Optional) - Comma separated list of properties to retrieve from $sSection. If set to "" all properties will be retrieved (default = "")

Remarks: For $iFormat = 1 if you only request a single property you will get a string holding the value of the property. Else you get an array as described above.
  All data returned by the function is in the format as retrieved from the Taskscheduler object.
  e.g. LogonType is of type Integer, UserId is returned as String.
Author: water
Goto Top

_TS_TaskPropertiesSet

_TS_TaskPropertiesSet(ByRef $oObject, $aProperties)
Description: Sets the properties of a Tasks object (Task Definition, RegisteredTask, Action or Trigger).
Return Value:
  Success - 1
  Failure - 0, sets @error to:
    2001 - Unsupported or invalid Task Scheduler COM object
    2002 - Unsupported or invalid property name. @extended is set to the zero based index of the property in error
    2003 - The row in $aProperties does not have the required format: "object name|property name|property value". @extended is set to the index of the row in error.
    2004 - $oObject is invalid. Must be: TaskDefinition, RegisteredTask, Trigger or Action
Parameters:
  $oObject - Object of a Task Definition, RegisteredTask, Action or Trigger
  $aProperties - one-dimensional zero based array in the following format: "object name|property name|property value"
    Name of the object to process. Valid are: TASK, DEFINITION, PRINCIPAL, REGISTRATIONINFO, SETTINGS, IDLESETTINGS, NETWORKSETTINGS, TRIGGERS, REPETITION and ACTIONS
    Name of the property to set
    Value for the property to set
Remarks: Sections that are not valid for the passed object are ignored!
  E.g. The "Task" section and its properties are only valid for a RegisteredTask object
Author: water
Goto Top

_TS_TaskRegister

_TS_TaskRegister($oService, $sFolder, $sName, $oTaskDefinition, $sUserId = Default, $sPassword = Default, $iLogonType = Default, $iCreateFlag = Default)
Description: Register or update a Task.
Return Value:
  Success - Task object
  Failure - Returns 0 and sets @error:
    2101 - Parameter $oService is not an object or not an ITaskService object
    2102 - $sFolder does not exist or an error occurred in _TS_FolderExists. @extended is set to the COM error (if any)
    2103 - Task exists which is incompatible with flags $TASK_CREATE, $TASK_DISABLE and $TASK_CREATE or
     Task does not exist which is incompatible with flags $TASK_UPDATE And $TASK_DONT_ADD_PRINCIPAL_ACE
    2104 - Parameter $oTaskDefinition is not an object or not an ITaskDefinition object
    2105 - Error accessing $sFolder using _TS_FolderGet. @extended is set to the COM error
    2106 - Error creating the Task. @extended is set to the COM error
Parameters:
  $oService - Task Scheduler Service object as returned by _TS_Open
  $sFolder - Folder where the Task should be created
  $sName - Name of the Task
  $oTaskDefinition - Task Definition object as created by _TS_TaskCreate and filled by _TS_TaskPropertiesSet
  $sUserId (Optional) - The user credentials that are used to register the Task. If present, these credentials

  take priority over the credentials specified in the Task Definition object pointed to by the definition parameter
  $sPassword (Optional) - The password for the UserId that is used to register the Task. When the TASK_LOGON_SERVICE_ACCOUNT logon type

  is used, the password must be an empty value such as NULL or ""
  $iLogonType (Optional) - Can be any of the TASK_LOGON_TYPE constants enumeration. For the default please check Remarks

  $iCreateFlag (Optional) - Defines if to create or update the task. Can be any of the TASK_CREATE constants enumeration. Default is $TASK_CREATE

Remarks: If the logon type has been set in the Principal sub-object then $TASK_LOGON_NONE is the default to not overwrite the existing setting.
  Else $TASK_LOGON_INTERACTIVE_TOKEN will be used as default.
Author: water
Goto Top

_TS_TaskRun

_TS_TaskRun($oService, $vTask)
Description: Run the Registered Task immediately.
Return Value:
  Success - A RunningTask Object that defines the new instance of the task.
  Failure - Returns 0 and sets @error
    2201 - The Task does not exist. @extended is set to the COM error code returned by _TS_TaskGet
    2202 - Error starting the Task. @extended is set to the COM error
Parameters:
  $oService - Task Scheduler Service object as returned by _TS_Open
  $vTask - Registered Task to run. Can be the object or a string e.g. "\folder\task"
Author: water
Goto Top

_TS_TaskStop

_TS_TaskStop($oService, $vTask)
Description: Stops all instances of the Registered Task immediately.
Return Value:
  Success - 1
  Failure - Returns 0 and sets @error
    2301 - The Task does not exist. @extended is set to the COM error code returned by _TS_TaskGet
    2302 - Error stopping the Task. @extended is set to the COM error
Parameters:
  $oService - Task Scheduler Service object as returned by _TS_Open
  $vTask - Registered Task to stop. Can be the object or a string e.g. "\folder\task"
Remarks: The function stops all instances of the task.
  System account users can stop a task, users with Administrator group privileges can stop a task,
  and if a user has rights to execute and read a task, then the user can stop the task.
  A user can stop the task instances that are running under the same credentials as the user account.
  In all other cases, the user is denied access to stop the task.
Author: water
Goto Top

_TS_TaskUpdate

_TS_TaskUpdate($oService, $oTask, $oTaskDefinition)
Description: Update a Task.
Return Value:
  Success - Task object
  Failure - Returns 0 and sets @error:
    3301 - Parameter $oService is not an object or not an ITaskService object
    3302 - Parameter $oTask is not an object or not an IRegisteredTask object
    3303 - Error accessing $sFolder using _TS_FolderGet. @extended is set to the COM error
    3304 - Error updating the Task. @extended is set to the COM error
    3305 - Parameter $oTaskDefinition is not an object or not an ITaskDefinition object
Parameters:
  $oService - Task Scheduler Service object as returned by _TS_Open
  $oTask - Registered Task object
  $oTaskDefinition - TaskDefinition object of the Registered Task
Author: water
Goto Top

_TS_TaskValidate

_TS_TaskValidate($oService, $vTask)
Description: Validate the Task Definition.
Return Value:
  Success - Returns a zero-based 2D array holding the following information:
    0 - Errornumber as described in section Remarks
    1 - Severity: I (Information), W (Warning, E (Error)
  Failure - Returns "" and sets @error
    2401 - The Task does not exist. @extended is set to the COM error code returned by _TS_TaskGet
    240101 - You have to define at least one Action
    240102 - Action type is unsupported
    240103 - Action ID has to be unique
    240501 - You should at least define one Trigger
    245001 - Make sure to provide Userid and Password for the selected logon type
Parameters:
  $oService - Task Scheduler Service object as returned by _TS_Open
  $vTask - Object to validate. Can be a Task Definition or a Registered Task object
  The Registered Task can be specified as a string as well e.g. "\folder\task"
Remarks: This function is necessary because the validate function of the Registration method does not return any meaningful results.
  The function first checks the integrity of each object (triggers, actions ...) then the task as a whole.
Author: water
Goto Top

_TS_TriggerCreate

_TS_TriggerCreate($oTaskDefinition, $iTriggerType, $sID = "")
Description: Create a new Trigger object for a new or already Registered Task.
Return Value:
  Success - Object of the created Trigger
  Failure - Returns 0 and sets @error
    2501 - $oTaskDefinition isn't an object or not a Task Definition object
    2502 - The Trigger could not be created. @extended is set to the COM error code
Parameters:
  $oTaskDefinition - Task Definition object to add this Trigger to.
  $iTriggerType - Type of Trigger to use. Can be any of the TASK_TRIGGER_TYPE2 enumeration
  $sID (Optional) - ID for easier access to the Trigger

Author: water
Goto Top

_TS_TriggerDelete

_TS_TriggerDelete($oTaskDefinition, $iIndex, $sID = "", $bDeleteAll = False)
Description: Delete a single or all Trigger objects by ID or index.
Return Value:
  Success - 1
  Failure - Returns 0 and sets @error:
    2602 - The Trigger could not be deleted. @extended is set to the COM error code
    2603 - The Triggers could not be deleted. @extended is set to the COM error code
    2604 - Either $iIndex or $sID has to be specified when $bDeleteAll is set to False
Parameters:
  $oTaskDefinition - Task Definition object of a new or Registered Task
  $iIndex - Delete the Trigger with the specified index (one based)
  $sID (Optional) - Deletes all Triggers with the same ID (default = "")

  $bDeleteAll (Optional) - Removes all Triggers (default = False)

Remarks: Set one of this three parameters to delete specific or all Triggers: $iIndex, $sID, $bDeleteAll.
  The parameters will be processed in the following sequence:
  If $iIndex > 0 then delete by index, else if $sID <> "" then delete by ID, else if $bDeleteAll is True then delete all Triggers
Author: water
Goto Top

_TS_VersionInfo

_TS_VersionInfo()
Description: Returns an array of information about the UDF.
Return Value:
  Success - one-dimensional one based array with the following information:
    1 - Release Type (T=Test or V=Production)
    2 - Major Version
    3 - Minor Version
    4 - Sub Version
    5 - Release Date (YYYYMMDD)
    6 - AutoIt version required
    7 - List of authors separated by ","
    8 - List of contributors separated by ","
Parameters:
  None
Remarks: Based on function _IE_VersionInfo written bei Dale Hohm
Author: water
Goto Top

_TS_Wrapper_ActionCreate

_TS_Wrapper_ActionCreate($oTaskDefinition, $sPath, $sWorkingDirectory = "", $sArguments = "")
Description: Create the Actions to be executed when the Task runs.
Return Value:
  Success - 1
  Failure - Returns 0 and sets @error:
    2701 - Error returned when accessing the Actions collection. @extended is set to the COM error code
    2702 - Error returned when creating the Action object. @extended is set to the COM error code
    2703 - Parameter $oTaskDefinition is not an object or not an ITaskDefinition object
Parameters:
  $oTaskDefinition - Task Definition object as returned by _TS_Wrapper_TaskCreate
  $sPath - Path to an executable file
  $sWorkingDirectory (Optional) - Directory that contains either the executable file or the files that are used by the executable file

  $sArguments (Optional) - Arguments pased to the executable file

Remarks: Populates the Action object
Author: water
Goto Top

_TS_Wrapper_PrincipalSet

_TS_Wrapper_PrincipalSet($oTaskDefinition, $iLogonType, $iRunLevel = $TASK_RUNLEVEL_LUA, $sUserId = "", $sGroupId = "")
Description: Set the Principal properties of a Task Definition object.
Return Value:
  Success - 1
  Failure - Returns 0 and sets @error:
    2801 - Error creating the Task Definition. @extended is set to the COM error code
    2802 - Parameter $oTaskDefinition is not an object or not an ITaskDefinition object
Parameters:
  $oTaskDefinition - Task Definition object as returned by _TS_Wrapper_TaskCreate
  $iLogonType - Sets the security logon method that is required to run the Tasks that are associated with the principal.
  Can be any of the TASK_LOGON_TYPE constants.
  $iRunLevel (Optional) - Sets the identifier that is used to specify the privilege level that is required to run the Tasks that are associated with the principal.

  Can be any of the TASK_RUNLEVEL_TYPE constants (default = $TASK_RUNLEVEL_LUA (Tasks will be run with the least privileges (LUA))
  $sUserId (Optional) - Sets the user identifier that is required to run the Tasks that are associated with the principal.

  $sGroupId (Optional) - Sets the group identifier that is required to run the Tasks that are associated with the principal.

Remarks: Populates the RegistrationInfo object.
  Either set $sUserId or $sGroupId - if any
Author: water
Goto Top

_TS_Wrapper_TaskCreate

_TS_Wrapper_TaskCreate($oService, $sDescription = "", $sDocumentation = "", $sAuthor = Default, $sDate = Default)
Description: Create a Task Definition object so you can then set all needed properties using other Wrapper functions.
Return Value:
  Success - Task Definition object
  Failure - Returns 0 and sets @error:
    2901 - Error creating the Task Definition. @extended is set to the COM error code
    2902 - Error setting property Date. Please check the correct format as described above. @extended is set to the COM error code
    2903 - Parameter $oService is not an object or not an ITaskService object
Parameters:
  $oService - Task Scheduler Service object as returned by _TS_Open
  $sDescription (Optional) - Describe the Task in a single line

  $sDocumentation (Optional) - Extended documentation of the Task

  $sAuthor (Optional) - Author of the Task. If not specified @UserName is used (default)

  $sDate (Optional) - Date when the Task was created. If not specified _Now() is usded (default)

  Format has to be: YYYY-MM-DD-THH:MM:SS
Remarks: Creates the Task Definition object and populates the RegistrationInfo object
Author: water
Goto Top

_TS_Wrapper_TaskRegister

_TS_Wrapper_TaskRegister($oService, $sFolder, $sName, $oTaskDefinition, $sUserId = Default, $sPassword = Default, $iLogonType = Default)
Description: Alias for _TS_TaskRegister: Register a Task in the specified Folder.
Remarks: For sections Parameters, Return values and Related please see function _TS_TaskRegister
Author: water
Goto Top

_TS_Wrapper_TriggerDateTime

_TS_Wrapper_TriggerDateTime($oTaskDefinition, $iTriggerType, $iDoW, $iInterval, $sStart, $sEnd = "")
Description: Creates a date/time based Trigger.
Return Value:
  Success - Object of the created schedule
  Failure - Returns 0 and sets @error
    3101 - Invalid $iTriggerType specified. Has to be $TASK_TRIGGER_TIME, $TASK_TRIGGER_DAILY or $TASK_TRIGGER_WEEKLY
    3102 - Error returned when creating the Trigger object. @extended is set to the COM error code
    3103 - Error setting property StartBoundary. Please check the correct format as described above. @extended is set to the COM error code
    3104 - Error setting property EndBoundary. Please check the correct format as described above. @extended is set to the COM error code
    3105 - Error setting property ExecutionTimeLimit. Please check the correct format as described above. @extended is set to the COM error code
    3106 - Error setting property DaysOfWeek. Please check the correct format. @extended is set to the COM error code
    3107 - Error setting property Weeksinterval. Please check the correct format. @extended is set to the COM error code
    3108 - Error setting property DaysInterval. Please check the correct format. @extended is set to the COM error code
    3109 - Parameter $oTaskDefinition is not an object or not an ITaskDefinition object
    3110 - Error returned when accessing the Triggers collection. @extended is set to the COM error code
Parameters:
  $oTaskDefinition - Task Definition object as returned by _TS_Wrapper_TaskCreate
  $iTriggerType - Type of Trigger to use. Only supports $TASK_TRIGGER_TIME, $TASK_TRIGGER_DAILY and $TASK_TRIGGER_WEEKLY
  $iDoW - A bitwise mask that indicates the days of the week on which the Task runs. Possible values:
    Sunday - 1, Monday - 2, Tuesday - 4, Wednesday - 8, Thursday - 16, Friday - 32, Saturday - 64. 10 means: Run the schedule on Monday and Wednesday
  $iInterval - The interval between the days ($TASK_TRIGGER_DAILY) or weeks ($TASK_TRIGGER_WEEKLY) in the schedule
  $sStart - The date and time when the Trigger is activated. Format: YYYY-MM-DDTHH:MM:SS(+-)HH:MM. See Remarks
  $sEnd (Optional) - The date and time when the Trigger is deactivated. Format: YYYY-MM-DDTHH:MM:SS(+-)HH:MM. See Remarks

Remarks: The (+-)HH:MM section describes the time zone as a certain number of hours ahead or behind Coordinated Universal Time (Greenwich Mean Time).
Author: water
Goto Top

_TS_Wrapper_TriggerLogon

_TS_Wrapper_TriggerLogon($oTaskDefinition, $iDelay, $sStart, $sEnd = "")
Description: Creates a logon Trigger.
Return Value:
  Success - Object of the created schedule
  Failure - Returns 0 and sets @error
    3201 - Error returned when creating the Trigger object. @extended is set to the COM error code
    3202 - Error setting property StartBoundary. Please check the correct format as described above. @extended is set to the COM error code
    3203 - Error setting property EndBoundary. Please check the correct format as described above. @extended is set to the COM error code
    3204 - Error setting property ExecutionTimeLimit. Please check the correct format as described above. @extended is set to the COM error code
    3205 - Error setting property Delay. Please check the correct format as described above. @extended is set to the COM error code
    3206 - Parameter $oTaskDefinition is not an object or not an ITaskDefinition object
    3207 - Error returned when accessing the Triggers collection. @extended is set to the COM error code
Parameters:
  $oTaskDefinition - Task Definition object as returned by _TS_Wrapper_TaskCreate
  $iDelay - Value in minutes indicating the time between the users logon and the start of the Task
  $sStart - The date and time when the Trigger is activated. Format: YYYY-MM-DDTHH:MM:SS(+-)HH:MM. See Remarks
  $sEnd (Optional) - The date and time when the Trigger is deactivated. Format: YYYY-MM-DDTHH:MM:SS(+-)HH:MM. See Remarks

Remarks: The (+-)HH:MM section describes the time zone as a certain number of hours ahead or behind Coordinated Universal Time (Greenwich Mean Time).
Author: water